{% include "iframe_header" %}

<div class="layuimini-main">

    <div class="layui-form layuimini-form">
        <form action="" class="layui-form" lay-filter="addform">
            <div class="layui-form-item">
                <label class="layui-form-label required">Symbol</label>
                <div class="layui-input-block">
                    <input type="hidden" name="id" value="">
                    <input type="text" name="symbol" lay-verify="required" lay-reqtext="不能为空" placeholder="usdjpy" value="" class="layui-input">
                    <tip>唯一的，不区分大小写，提交后不可修改</tip>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required" lay-reqtext="不能为空" placeholder="美元日元" value="" class="layui-input">
                    <tip></tip>
                </div>
            </div>

            
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label required">交易</label>
                    <div class="layui-input-inline">
                        <select name="target_symbol_id" lay-verify="required" lay-reqtext="不能为空">
                            <option value="">请选择</option>
                            {% range $k,$v := .all_variteties %}
                            <option value="{%$v.Id%}">{%$v.Name%}/{%$v.Symbol%}</option>
                            {%end%}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label required">基础货币</label>
                    <div class="layui-input-inline">
                        <select name="base_symbol_id" lay-verify="required" lay-reqtext="不能为空">
                            <option value="">请选择</option>
                            {% range $k,$v := .all_variteties %}
                            <option value="{%$v.Id%}">{%$v.Name%}/{%$v.Symbol%}</option>
                            {%end%}
                        </select>
                    </div>
                </div>
                <tip>提交后不可修改</tip>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label required">价格精度</label>
                <div class="layui-input-block">
                    <input type="number" name="price_precision" lay-verify="required" lay-reqtext="" placeholder="8" value="" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">数量精度</label>
                <div class="layui-input-block">
                    <input type="number" name="qty_precision" lay-verify="required" lay-reqtext="" placeholder="3" value="" class="layui-input">
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label required">数量</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="number" name="allow_min_qty" placeholder="0.01" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid">～</div>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="number" name="allow_max_qty" placeholder="0为不限制" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label required">金额</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="number" name="allow_min_amount" placeholder="0" autocomplete="off" class="layui-input">
                    </div>
                    <div class="layui-form-mid">～</div>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input type="number" name="allow_max_amount" placeholder="0为不限制" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>

        

            <div class="layui-form-item">
                <label class="layui-form-label required">交易费率</label>
                <div class="layui-input-block">
                    <input type="number" name="fee_rate" lay-verify="required" lay-reqtext="" placeholder="0.005" value="" class="layui-input">
                    <tip>0.005表示收取千分之五的交易手续费</tip>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">排序</label>
                <div class="layui-input-block">
                    <input type="number" name="sort" lay-reqtext="" placeholder="0" value="" class="layui-input">
                    <tip>值越小越靠前</tip>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="0" title="正常" checked="">
                    <input type="radio" name="status" value="1" title="禁用">
                </div>
            </div>
            
            

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use(['form', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;

        form.render();
        




        //监听提交
        form.on('submit(saveBtn)', function (data) {
            $.ajax({
                url: "/admin/tradingvarieties/add?id=" +data.field.id,
                type: "post",
                data: data.field,
                success: function(d){
                    if(d.ok){
                        layer.msg("成功");
                    }else{
                        layer.alert(d.reason);
                    }
                }
            })

            return false;
        });

        
        form.val("addform", {
            "id": {% .data.Id %},
            "symbol": {% .data.Symbol %},
            "name": {% .data.Name %},
            "price_precision": {% .data.PricePrecision %},
            "qty_precision": {% .data.QtyPrecision %},
            "target_symbol_id": {% .data.TargetSymbolId%},
            "base_symbol_id": {% .data.BaseSymbolId%},
            "allow_min_qty": {% .data.AllowMinQty%},
            "allow_max_qty": {% .data.AllowMaxQty%},
            "allow_min_amount": {% .data.AllowMinAmount%},
            "allow_max_amount": {% .data.AllowMaxAmount%},
            "fee_rate": {% .data.FeeRate%},
            "sort": {% .data.Sort%},
            "status": {% .data.Status %}
        });

    });
</script>


{% include "iframe_footer" %}